/**
 * ControllerCommand.java
 */
package commands.controller;

import commands.*;

/**
 * @author Michal Kolodziejski
 * @author Marcin Kamionowski
 * @author Jakub Skierbiszewski
 */
public class ControllerCommand extends Command {

    public enum ControllerCommandType {

        /** request for data to refresh */
        GUI_REFRESH_DOWNLOAD_STATUS_ALL,
        /** request to stop downloading */
        GUI_STOP_DOWNLOAD_FILE,
        /** request to start downloading */
        GUI_START_DOWNLOAD_FILE,
        /** add download to list */
        GUI_ADD_DOWNLOAD,
        /** delete download from list */
        GUI_DEL_DOWNLOAD,
        /** add file to shared */
        GUI_ADD_SHARED,
        /** remove file from shared */
        GUI_DEL_SHARED,
        /** set prority for download task */
        GUI_MOVE_DOWNLOAD_FILE,
        /** request for searching file */
        GUI_SEARCH,
        /** request to close application */
        GUI_EXIT,
        /** set new user properties */
        GUI_SET_PREFERENCES,
        /** get properties to display */
        GUI_GET_PREFERENCES,
        /** request for active hosts */
        GUI_GET_ACTIVE_HOSTS,
        
        /** command returning results of a file search in shared files */
        MODEL_SEARCH_RESULTS,
        /** command returning a list of shared files */
        MODEL_SHARED_FILES_LIST,
        /** command returning a list of download files */
        MODEL_DOWNLOAD_FILES_LIST,
        /** reports a change of the state of the download file */
        MODEL_DOWNLOAD_FILE_STATE_CHANGED,
        /** command returning a list of hosts hosting specified download file */
        MODEL_DOWNLOAD_FILE_HOSTS_LIST,
        /** reports the end of a download of the file */
        MODEL_DOWNLOAD_FINISHED,
        /** command returning a number of next lacking part of the download file */
        MODEL_NEXT_LACKING_PART,
        /** command returning a next host hosting the specified download file */
        MODEL_NEXT_HOST,
        /** command returning requested part of the file */
        MODEL_PART_OF_FILE,
        /** command returning a number of maximum active connections */
        MODEL_MAX_ACTIVE_CONNECTIONS_NUMBER,
        /** command confirming saving configuration */
        MODEL_CONFIGURATION_SAVED,
        /** command returning information if a file is on the list of shared files */
        MODEL_IS_SHARED_FILE_RESPONSE,

        /** command containing incoming search result */
        NC_SEARCH_RESULT,
        /** command informing that some host is alive */
        NC_HOST_ALIVE,
        /** contains requested segment */
        NC_PART_OF_FILE,
        /** command containing incoming search request */
        NC_SEARCH_QUERY,
        /** request for a segment */
        NC_GET_SEGMENT,
        /** Number of free connections (for download) */
        NC_FREE_CONNECTIONS,
        /** Command informing that part of file is not downloaded */
        NC_PART_TIMEOUT,
        
        /** Command requesting refresh of files download list */
        CC_GET_FILES_HOSTS
    };
    private final ControllerCommandType commandType;

    public ControllerCommand(ControllerCommandType cct) {
        super(CommandReceiverType.CONTROLLER);
        commandType = cct;
    }

    public ControllerCommandType getCommandType() {
        return commandType;
    }

    @Override
    public String toString() {
        StringBuilder toStringBuilder = new StringBuilder();
        toStringBuilder.append(super.toString());
        toStringBuilder.append("\n");
        toStringBuilder.append("\ncommandType: ");
        toStringBuilder.append(commandType);
        return toStringBuilder.toString();
    }
}
